import 'package:flutter/material.dart';
import 'hermit/test_page.dart';
import 'hermit/flutter_provide.dart';
import 'package:provide/provide.dart';
import '../provide/count.dart';

class HermitPage extends StatefulWidget {
  @override
  _HermitPageState createState() => _HermitPageState();
}

class _HermitPageState extends State<HermitPage> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '学习页面',
      home: Scaffold(
        appBar: new AppBar(
          title: Text('欢迎回家'),
          backgroundColor: new Color.fromARGB(23, 123, 34, 3),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              jumpTextButton(),
              flutterProvide(),
              showFlutterProvide(),
            ],
          ),
        ),
      ),
    );
  }

  // 跳转页面测试
  Widget jumpTextButton() {
    return Container(
      child: RaisedButton(
        child: Text('跳转测试,测试码云代码管理11'),
        onPressed: () {
          Navigator.push(context, new MaterialPageRoute(
              builder: (context) => new TestPage()
          ));
        },
      ),
    );
  }

  // 状态管理测试
  Widget flutterProvide() {
    return Container(
      child: RaisedButton(
        child: Text('状态管理测试'),
        onPressed: () {
          Navigator.push(context, new MaterialPageRoute(
              builder: (context) => new FlutterProvide()
          ));
        },
      ),
    );
  }

  // 状态管理 显示
  Widget showFlutterProvide() {
    return Container(
      child: Provide<Counter>(
        builder: (context, child, counter){
          return Text(
            '${counter.value}'
          );
        },
      )
    );
  }
}

